
<?PHP 

Util::tsRegisterAssetJs('_tarea_objetivo_modal.js');
?>

<div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h4><i class="icon-tasks"></i> Objetivos</h4>
</div>
<div class="modal-body"><?php
    Yii::app()->clientScript->scriptMap['jquery.js'] = false;

//    Yii::app()->clientScript->registerCss('tareaObjetivo' . $model->id, '
//    .realizado
//        { 
//        text-decoration: line-through;  
//        }
//    .no_realizado
//        {
//        text-decoration: none;
//        }
//    ');
    ?>
    <?php
    $modelTareaObjetivo = new TareaObjetivo();
    $modelTareaObjetivo->tarea_id = $model->id;
    $modelTareaObjetivo->realizado = 0;
    $form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
        'id' => 'tarea-objetivo-form',
        'type' => 'vertical',
        'enableAjaxValidation' => true,
        'clientOptions' => array('validateOnSubmit' => false, 'validateOnChange' => false,),
        'enableClientValidation' => false,
    ));
    ?>

    <?php echo $form->textFieldRow($modelTareaObjetivo, 'objetivo', array('class' => 'span12', 'maxlength' => 254)) ?>
    <?php echo $form->hiddenField($modelTareaObjetivo, 'tarea_id') ?>
    <?php echo $form->hiddenField($modelTareaObjetivo, 'realizado') ?>


    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'type' => 'success',
        'icon' => 'ok',
        'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
        'htmlOptions' => array(
            'onclick' => 'js:guardarObjetivo("' . CController::createUrl('/tareas/tarea/guardarObjetivo') . '")',
        ),
    ))
    ?>

    <?php $this->endWidget(); ?>
    <br>
    <?php
    $this->widget(
            'bootstrap.widgets.TbProgress', array(
        'type' => 'success', // 'info', 'success' or 'danger'
        'percent' => $datos['porcentaje_no_realizadas'],
//            'striped' => true,
//            'animated' => true,
        'htmlOptions' => array(
            'id' => 'progresoObjetivo',
        )
            )
    );
    ?>
    <?php
    $modelTareaObjetivo->unsetAttributes();
    $modelTareaObjetivo->tarea_id = $model->id;
    $this->widget('ext.bootstrap.widgets.TbGridView', array(
        'id' => 'objetivo-grid',
//            'type' => 'striped bordered hover advance',
        'showTableOnEmpty' => false,
        'emptyText' => '',
        'selectableRows' => 2,
        "template" => "{items}{summary}{pager}",
//        'afterAjaxUpdate' => "function(id,data){ 
//    $('.realizado').attr('style', 'text-decoration: line-through');
//    $('.no_realizado').attr('style', 'text-decoration: none'); }",
        
        'afterAjaxUpdate' => 'function(id,data){agregarEstilos();}',
        'hideHeader' => true,
        'dataProvider' => $modelTareaObjetivo->search(),
        'columns' => array(
//                'id',
            array(
                'name' => 'realizado',
                'class' => 'CCheckBoxColumn',
                'value' => '$data->id',
                'checked' => '$data->realizado',
                'htmlOptions' => array(
                    'width' => '20px',
                ),
                'checkBoxHtmlOptions' => array(
//                        'onclick' => 'js:cambioEstadoObjetivo($(this).val())'
                )
            ),
            array(
                'name' => 'objetivo',
                'value' => '$data->objetivo',
                'htmlOptions' => array(
                ),
                'cssClassExpression' => '$data->realizado?"realizado":"no_realizado"',
                'type' => 'raw'
            ),
//                'objetivo',
//                'realizado',
            array(
                'class' => 'CButtonColumn',
                'afterDelete' => 'function(link,success,data){ 
                            $("#progresoObjetivo > div").attr("style", "width:" + data + "%"); 
                            }',
                'template' => '{delete}',
                'buttons' => array(
                    'delete' => array(
                        'url' => 'Yii::app()->createUrl("/tareas/tarea/deleteObjetivo", array("id"=>$data->id))',
                        'label' => '<button class="btn btn-danger"><i class="icon-trash"></i></button>',
                        'options' => array('title' => 'Eliminar'),
                        'imageUrl' => false,
//                            'visible' => 'Util::checkAccess(array("action_nota_delete"))'
                    ),
                ),
            ),
        )
            )
    );
    ?>
</div>